package org.opens.hex;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.*;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class NmcPackageGrid {

    private String id;

    private Integer length;

    private Integer type;

    private String dynamicLengthId;

    public static Map<String, NmcPackageGrid> listMap = new HashMap<>();

    static {
        listMap.put("11", new NmcPackageGrid("11", 2, TypeConstant.INPUT, null));
        listMap.put("12", new NmcPackageGrid("12", 4, TypeConstant.SELECT, null));
        listMap.put("13", new NmcPackageGrid("13", 2, TypeConstant.INPUT, null));
        listMap.put("14", new NmcPackageGrid("14", 2, TypeConstant.BYTE_STREAM, "13"));
        listMap.put("15", new NmcPackageGrid("15", 2, TypeConstant.INPUT, null));
        listMap.put("16", new NmcPackageGrid("16", 2, TypeConstant.BYTE_STREAM_GROUP, "15"));

        listMap.put("17", new NmcPackageGrid("17", 2, TypeConstant.INPUT, null));
        listMap.put("18", new NmcPackageGrid("18", 4, TypeConstant.SELECT, null));
        listMap.put("19", new NmcPackageGrid("19", 2, TypeConstant.INPUT, null));
        listMap.put("20", new NmcPackageGrid("20", 2, TypeConstant.BYTE_STREAM, "19"));
        listMap.put("21", new NmcPackageGrid("21", 2, TypeConstant.INPUT, null));
        listMap.put("22", new NmcPackageGrid("22", 2, TypeConstant.INPUT, null));
        listMap.put("23", new NmcPackageGrid("23", 2, TypeConstant.BYTE_STREAM_GROUP, "22"));
        listMap.put("24", new NmcPackageGrid("24", 2, TypeConstant.INPUT, null));
    }

    public static NmcPackageGrid getById(String id) {
        return listMap.get(id);
    }

    public static List<NmcPackageGrid> getByIds(List<String> ids) {
        List<NmcPackageGrid> result = new ArrayList<>();
        for (String id : ids) {
            result.add(listMap.get(id));
        }
        return result;
    }

}
